package hk.com.fwd.biz.assembler;

import hk.com.fwd.entity.Original;
import hk.com.fwd.model.OriginalDTO;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

public class OriginalAssembler {

	public static OriginalDTO toDTO(Original entity) {
		OriginalDTO dto = new OriginalDTO();
		BeanUtils.copyProperties(entity, dto);
		return dto;
	}
	
	public static List<OriginalDTO> toDTOs(List<Original> entities){
		List<OriginalDTO> dtos = new ArrayList<>();
		for(Original entity:entities) {
			dtos.add(toDTO(entity));
		}
		return dtos;
	}
	
	public static Original toEntity(OriginalDTO dto) {
		Original entity = new Original();
		BeanUtils.copyProperties(dto, entity);
		return entity;
	}
	
	public static List<Original> toEntities(List<OriginalDTO> dtos){
		List<Original> entities = new ArrayList<>();
		for(OriginalDTO dto:dtos) {
			entities.add(toEntity(dto));
		}
		return entities;
	}
}
